<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 根据提供的数据 （arr,headersArr,headersRelations）转换成目标数据
    const arr = [
      {
        "id": "604f764971f93f3ac8f365c2",
        "mobile": "13800000002",
        "username": "乐哥牛啤",
        "password": "e10adc3949ba59abbe56e057f20f883e",
        "timeOfEntry": "2018-11-23",
        "formOfEmployment": 1,
        "workNumber": "503",
        "correctionTime": "2018-11-30",
        "departmentName": "哈哈",
        "staffPhoto": ""
      },
      {
        "id": "604f764971f93f3ac8f365c3",
        "mobile": "13800000003",
        "username": "张三",
        "password": "9fab6755cd2e8817d3e73b0978ca54a6",
        "timeOfEntry": "2018-11-04",
        "formOfEmployment": 1,
        "workNumber": "111",
        "correctionTime": "2018-11-20",
        "departmentName": "市场部",
        "staffPhoto": "http://fwq666-1314223958.cos.ap-beijing.myqcloud.com/%E5%A4%B4%E5%83%8F.jpg"
      }
    ]
    const headersArr = ['姓名', '手机号', '入职日期', '聘用形式', '转正日期', '工号', '部门']
    const headersRelations = {
      '姓名': 'username',
      '手机号': 'mobile',
      '入职日期': 'timeOfEntry',
      '聘用形式': 'formOfEmployment',
      '转正日期': 'correctionTime',
      '工号': 'workNumber',
      '部门': 'departmentName'
    }

    let list = []
    arr.forEach(item => {
      let tempArr = []
      headersArr.forEach(header => {
        const englishKey = headersRelations[header]
        tempArr.push(item[englishKey])
      })
      list.push(tempArr)
    })
    console.log(list)
    // 目标数据格式如下：
    // 1.目标数据是个二维数组
    // 2.目标数据中的每一个小数组的每一项的顺序 和  headersArr是对应的
    // 3.目标数据中每一个小数组的值 是从arr中的每一个对象中取出来
    // [
    //   ['乐哥牛啤', '13800000002', '2018-11-23', 1, '2018-11-30', '503', '哈哈'],
    //   ['张三', '13800000003', '2018-11-04', 1, '2018-11-20', '111', '市场部']
    // ]
  </script>
</body>

</html>